#ifndef ABSTRACTMODELITEM_H
#define ABSTRACTMODELITEM_H

#include "model_global.h"
#include <QObject>

class MODELSHARED_EXPORT AbstractModelItem : public QObject
{
    Q_OBJECT

public:

    explicit AbstractModelItem(QObject *parent = 0);
    AbstractModelItem(const AbstractModelItem& other);

    static AbstractModelItem* create(int type, QObject* parent = 0);

    template <typename T>
    static T create(int type, QObject *parent = 0)
    {
        return qobject_cast<T>(create(type, parent));
    }
//    static AbstractModelItem* create(const QString& typeName, QObject* parent = 0);

    const AbstractModelItem *root() const;

    QList<AbstractModelItem*> childItems() const;

    virtual int type() const;

    virtual int fieldCount() const = 0;
    virtual QVariant value(int field, int role = Qt::DisplayRole) const = 0;
    virtual bool setValue(int field, const QVariant& value, int role = Qt::EditRole) = 0;

    virtual QVariant fieldName(int field) const = 0;

    void setParent(QObject * object);


signals:

    void sigChanged();
    void sigFieldCountChanged();


protected slots:

    virtual void onReparent();

    virtual void onInitialize();

    
};

#endif // ABSTRACTMODELITEM_H
